﻿using BussinessObject.ObjectTwo;
using Class_Entity.ObjectTwo;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ProjectHK3.App_Code;

namespace ProjectHK3.Object_One
{
    public partial class ServiceDetail : System.Web.UI.Page
    {
        B_Search bs = new B_Search();
        C_Services ser = new C_Services();
        B_Update mn = new B_Update();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                load();
            }
        }
        public void load()
        {
            ser = bs.loadService(int.Parse(Session["Sevice"].ToString()));
            TextBox1.Text = ser.SERVICE_CODE;
            TextBox2.Text = ser.SERVICE_NAME;
            TextBox3.Text = ser.DESCRIPTION;
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            int tam = int.Parse(Session["Sevice"].ToString());
            ser.SERVICE_ID = int.Parse(Session["Sevice"].ToString()); ;
            ser.SERVICE_CODE = TextBox1.Text;
            ser.SERVICE_NAME = TextBox2.Text;
            ser.DESCRIPTION = TextBox3.Text;

            if (mn.updateService(ser) == true)
            {
                Alert.Show("Update Successful");
                load();
            }
            else
            {
                Alert.Show("false");
                load();
            }
            ;
        }

        protected void Button3_Click(object sender, EventArgs e)
        {
            TextBox1.Text = "";
            TextBox2.Text = "";
            TextBox3.Text = "";
            TextBox1.Focus();
        }
    }
}